package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.system.domain.WdyKline;
import com.ruoyi.system.service.IWdyKlineService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 1分钟k线 信息操作处理
 * 
 * @author ruoyi
 * @date 2020-01-10
 */
@Controller
@RequestMapping("/system/wdyKline")
public class WdyKlineController extends BaseController
{
    private String prefix = "system/wdyKline";
	
	@Autowired
	private IWdyKlineService wdyKlineService;
	
	@RequiresPermissions("system:wdyKline:view")
	@GetMapping()
	public String wdyKline()
	{
	    return prefix + "/wdyKline";
	}
	
	/**
	 * 查询1分钟k线列表
	 */
	@RequiresPermissions("system:wdyKline:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(WdyKline wdyKline)
	{
		startPage();
        List<WdyKline> list = wdyKlineService.selectWdyKlineList(wdyKline);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出1分钟k线列表
	 */
	@RequiresPermissions("system:wdyKline:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WdyKline wdyKline)
    {
    	List<WdyKline> list = wdyKlineService.selectWdyKlineList(wdyKline);
        ExcelUtil<WdyKline> util = new ExcelUtil<WdyKline>(WdyKline.class);
        return util.exportExcel(list, "wdyKline");
    }
	
	/**
	 * 新增1分钟k线
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存1分钟k线
	 */
	@RequiresPermissions("system:wdyKline:add")
	@Log(title = "1分钟k线", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(WdyKline wdyKline)
	{		
		return toAjax(wdyKlineService.insertWdyKline(wdyKline));
	}

	/**
	 * 修改1分钟k线
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Long id, ModelMap mmap)
	{
		WdyKline wdyKline = wdyKlineService.selectWdyKlineById(id);
		mmap.put("wdyKline", wdyKline);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存1分钟k线
	 */
	@RequiresPermissions("system:wdyKline:edit")
	@Log(title = "1分钟k线", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(WdyKline wdyKline)
	{		
		return toAjax(wdyKlineService.updateWdyKline(wdyKline));
	}
	
	/**
	 * 删除1分钟k线
	 */
	@RequiresPermissions("system:wdyKline:remove")
	@Log(title = "1分钟k线", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(wdyKlineService.deleteWdyKlineByIds(ids));
	}
	
}
